Solve Closest Facility
- URL:http://<nalayer-url>/solveClosestFacility
- Version Introduced:10.0
Description
The solve operation is performed on a network layer resource of type closest facility.
You can provide arguments to the Solve Route operation as query parameters defined in the parameters table below.
Added at 10.5
The overrides parameter allows you to specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems.
Added at 10.4
Pass in a complete JSON representation of a travel mode through travelMode and automatically set override values for various other parameters to quickly and consistently model cars, trucks, a type of truck, and so on.
Added at 10.3
Set travelMode and automatically set override values for various other parameters to quickly and consistently model cars, trucks, a type of truck, and so on.
Added at 10.2.1
The timeOfDayIsUTC parameter allows you to specify whether timeOfDay is in UTC or the time zone of the facilities or incidents. By using timeOfDayIsUTC, you can have all routes start or end at the same time regardless of the time zone where the facilities and incidents are located.
Added at 10.1
- M values—The OutputLines parameter supports a new value: esriNAOutputLineTrueShapeWithMeasure. If specified, returned routes, compressed geometry, and service area lines will contain M values on each vertex.
- Z values—The Closest Facility solver supports a new returnZ parameter. If returnZ=true and the Closest Facility solver is running against z-aware network dataset, returned routes and compressed geometry will contain z-values on each vertex. Input point and line locations can have z-values on them.
- Routes—Directions in the response include properties hasZ and/or hasM to indicate if the geometry includes z or m.
- CompressedGeometry—CompressedGeometry is capable of containing m- and z-values. How to decompress m- and z-values: Code Gallery sample code.
- Optional url property to specify input facilities, incidents, barriers, polylinebarriers, or polygonbarriers. The url value contains a REST Query request to a feature, map, or geoprocessing service returning a JSON feature set. The advantage of using this format is that locations can be passed directly from a service endpoint as input to the NA operation, bypassing client as intermediate storage.
- TimeOfDay, TimeOfDayUsage—The 10.1 Closest Facility solver is time aware and can be used in conjunction with historic and real-time traffic information.
Request Parameters
Parameter |
Details |
---|---|
f |
Description: The response format. The default response format is html. Values: html | json |
facilities |
Description: The set of facilities loaded as network locations during analysis. Facilities can be specified using a simple comma/semicolon-based syntax or as a JSON structure. If facilities are not specified, preloaded facilities from the map document are used in the analysis. If an empty JSON object is passed ('{}'), preloaded facilities are ignored. Syntax and Examples: Simple syntax: You can use a simple comma/semicolon-based syntax if you need to specify only facility point geometries in the default spatial reference or WGS84. Syntax: facilities=x1,y1; x2, y2; ...; xn, yn Example: facilities=-122.406, 37.7831; -122.405, 37.7827 JSON structures: Using JSON structures, you can specify two types of facilities:
Features You can specify facility geometries as well as attributes using a more comprehensive JSON structure. The JSON structure can include the following properties:
Each feature in this array represents a facility and it contains the following fields:
Syntax 1: Using features:
Example:
Syntax 2: Using url: (This option was added at 10.1.)
Example:
Layer You can specify facilities by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:
Syntax:
Example:
|
incidents |
Description: The set of incidents loaded as network locations during analysis. Incidents can be specified using a simple comma/semicolon-based syntax or as a JSON structure. If incidents are not specified, preloaded incidents from the map document are used in the analysis. If an empty JSON object is passed ('{}'), preloaded incidents are ignored. Syntax and Examples: Simple syntax: You can use a simple comma/semicolon-based syntax if you need to specify only incident point geometries in the default spatial reference or WGS84. Syntax: incidents=x1,y1; x2, y2; ...; xn, yn Example: incidents=-122.406, 37.7831; -122.405, 37.7827 JSON Structures: Using JSON structures, you can specify two types of incidents:
Features You can specify incident geometries as well as attributes using a more comprehensive JSON structure. The JSON structure can include the following properties:
Each feature in this array represents an incident and it contains the following fields:
Syntax:
Example:
Syntax 2: Using url: (This option was added at 10.1.)
Example:
Layer You can specify an incident by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:
Syntax:
Example:
|
barriers |
Description: The set of barriers loaded as network locations during analysis. Barriers can be specified using a simple comma/semicolon-based syntax or as a JSON structure. If barriers are not specified, preloaded barriers from the map document are used in the analysis. If an empty JSON object is passed ('{}'), preloaded barriers are ignored. Syntax and Examples: Simple syntax: You can use a simple comma/semicolon-based syntax if you need to specify only barrier point geometries in the default spatial reference or WGS84. Syntax: barriers=x1,y1; x2, y2; ...; xn, yn Example: barriers=-122.406, 37.7831; -122.405, 37.7827 JSON Structures: Using JSON structures, you can specify two types of barriers:
Features You can specify barrier geometries as well as attributes using a more comprehensive JSON structure. The JSON structure can include the following properties:
Each feature in this array represents a barrier and it contains the following fields:
Syntax:
Example:
Syntax 2: Using url: (This option was added at 10.1.)
Example:
Layer You can specify barriers by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:
Syntax:
Example:
|
polylineBarriers |
Description: The set of polyline barriers loaded as network locations during analysis. If polyline barriers are not specified, preloaded barriers from the map document are used in the analysis. If an empty JSON object is passed ('{}') preloaded polyline barriers are ignored. Syntax and Examples: JSON Structures: Using JSON structures, you can specify two types of barriers:
Features You can specify polyline barrier geometries as well as attributes using a more comprehensive JSON structure. The JSON structure can include the following properties:
Each feature in this array represents a barrier and it contains the following fields:
Syntax:
Example:
Syntax 2: Using url: (This option was added at 10.1.)
Layer You can specify polyline barriers by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:
Syntax:
Example:
|
polygonBarriers |
Description: The set of polygon barriers loaded as network locations during analysis. If polygon barriers are not specified, preloaded polygon barriers from the map document are used in the analysis. If an empty JSON object is passed ('{}'), preloaded polygon barriers are ignored. Syntax and Examples: JSON structures: Using JSON structures, you can specify two types of barriers:
Features You can specify polygon barrier geometries as well as attributes using a more comprehensive JSON structure. The JSON structure can include the following properties:
Each feature in this array represents a barrier and it contains the following fields:
Syntax:
Example:
Syntax 2: Using url: (This option was added at 10.1.)
Example:
Layer You can specify polygon barriers by referencing a data layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:
Syntax:
Example:
|
travelMode |
Added at 10.4 Travel modes provide override values that help you quickly and consistently model a vehicle or mode of transportation. By setting a travel mode, you don't need to explicitly set values for the following parameters:
Caution: When setting travelMode, the service overrides the values of the parameters listed above with those defined in the travel mode, even if you specify their values explicitly in the request. Example: To use an existing travel mode that was preconfigured in the service, the typical workflow would be as follows:
|
attributeParameterValues |
Description: A set of attribute parameter values that can be parameterized to determine which network elements can be used by a vehicle. The parameter holding a vehicle characteristic is compared to a value coming from a descriptor attribute to determine whether or not a network element is traversable. For example, a parameterized restriction attribute can compare the height of your vehicle with a descriptor attribute that holds the clearance under overpasses through tunnels. If the vehicles height is greater than the clearance, the edge is restricted. Parameterized cost attributes that can reference other cost attributes and scale them can also be used. This is useful when inclement weather, such as ice, fog or heavy rain, descends on the study area and hinders normal flow of traffic. By having a parameter already outfitted on a cost attribute, travel-time expectations and traversable network paths can be adjusted with respect to changes in traffic speeds. Syntax:
Example:
|
returnDirections |
Description: If true, directions will be generated and returned with the analysis results. Default is true. The directions are available in the directions property of the JSON response. Values: true | false |
directionsLanguage |
Description: The language to be used when computing directions. The default is as defined in the network layer. The list of supported languages can be found in the REST layer description. Example: directionsLanguage=en |
directionsOutputType |
Description: Defines content, verbosity of returned directions. The default is esriDOTStandard. Values: esriDOTComplete | esriDOTCompleteNoEvents | esriDOTFeatureSets | esriDOTInstructionsOnly | esriDOTStandard | esriDOTSummaryOnly |
directionsStyleName |
Description: The style to be used when returning the directions. The default is as defined in the network layer. The list of supported styles can be found in the REST layer description. Example: directionsStyleName=NA Navigation |
directionsLengthUnits |
Description: The length units to use when computing directions. The default is as defined in the network layer. Values: esriNAUFeet | esriNAUKilometers | esriNAUMeters | esriNAUMiles | esriNAUNauticalMiles | esriNAUYards | esriNAUUnknown |
directionsTimeAttributeName |
Description: The name of network attribute to use for the drive time when computing directions. The default is as defined in the network layer. Example: directionsTimeAttributeName=DriveTime |
returnCFRoutes |
Description: If true, closest facilities routes will be returned with the analysis results. Default is true. The routes are available in the routes property of the JSON response. Values: true | false |
returnFacilities |
Description: If true, facilities will be returned with the analysis results. Default is false. The facilities are available in the facilities property of the JSON response. Values: true | false |
returnIncidents |
Description: If true, incidents will be returned with the analysis results. Default is false. The incidents are available in the incidents property of the JSON response. Values: true | false |
returnBarriers |
Description: If true, barriers will be returned with the analysis results. Default is false. The barriers are available in the barriers property of the JSON response. Values: true | false |
returnPolylineBarriers |
Description: If true, polyline barriers will be returned with the analysis results. Default is false. The polyline barriers are available in the polylineBarriers property of the JSON response. Values: true | false |
returnPolygonBarriers |
Description: If true, polygon barriers will be returned with the analysis results. Default is false. The polygon barriers are available in the polygonBarriers property of the JSON response. Values: true | false |
outputLines |
Description: The type of output lines to be generated in the result. The default is as defined in the network layer. Values: esriNAOutputLineNone | esriNAOutputLineStraight | esriNAOutputLineTrueShape | esriNAOutputLineTrueShapeWithMeasure |
defaultCutoff |
Description: The default cutoff value to stop traversing. Values: <double> |
defaultTargetFacilityCount |
Description: The default number of facilities to find. Values: <integer> |
travelDirection |
Description: Options for traveling to or from the facility. The default is defined in the network layer. Values: esriNATravelDirectionFromFacility | esriNATravelDirectionToFacility |
outSR |
Description: The well-known ID of the spatial reference for the geometries returned with the analysis results. If outSR is not specified, the geometries are returned in the spatial reference of the map. |
accumulateAttributeNames |
Description: The list of network attribute names to be accumulated with the analysis. The default is as defined in the network layer. The value should be specified as a comma separated list of attribute names. You can also specify a value of none to indicate that no network attributes should be accumulated. Example: accumulateAttributeNames=WalkingMinutes,Meters |
impedanceAttributeName |
Description: The network attribute name to be used as the impedance attribute in analysis. The default is as defined in the network layer. Example: impedanceAttributeName=DrivingMinutes |
restrictionAttributeNames |
Description: The list of network attribute names to be used as restrictions with the analysis. The default is as defined in the network layer. The value should be specified as a comma separated list of attribute names. You can also specify a value of none to indicate that no network attributes should be used as restrictions. Example: restrictionAttributeNames=Oneway |
restrictUTurns |
Description: Specifies how U-Turns should be restricted in the analysis. The default is as defined in the network layer. Values: esriNFSBAllowBacktrack | esriNFSBAtDeadEndsOnly | esriNFSBNoBacktrack | esriNFSBAtDeadEndsAndIntersections |
useHierarchy |
Description: If true, the hierarchy attribute for the network should be used in analysis. The default is as defined in the network layer. Values: true | false |
outputGeometryPrecision |
Description: The precision of the output geometry after generalization. If 0, no generalization of output geometry is performed. The default is as defined in the network service configuration. If present and positive, it represents the MaximumAllowableOffset parameter—generalization is performed according to IPolycurve.Generalize. Example: outputGeometryPrecision=0.5 |
outputGeometryPrecisionUnits |
Description: The units of the output geometry precision. The default value is esriUnknownUnits. Values: esriUnknownUnits | esriCentimeters | esriDecimalDegrees | esriDecimeters | esriFeet | esriInches | esriKilometers | esriMeters | esriMiles | esriMillimeters | esriNauticalMiles | esriPoints | esriYards |
timeOfDay |
Description: Arrival or departure date and time. For example, if travelDirection is set to esriNATravelDirectionToFacility and timeOfDayUsage is set to esriNATimeOfDayUseAsEndTime and timeOfDay is set to 8:00 AM, the route(s) built will arrive at the Facility at 8:00 in the morning local time. This example assumes timeOfDayIsUTC is set to the default value of false. If the value is true, the facility is reached at 8:00 a.m. UTC. Values: Specified by number of milliseconds since midnight Jan 1st, 1970, UTC. |
timeOfDayIsUTC |
This option was added at 10.2.1. Description: The time zone of the timeOfDay parameter. By setting this parameter to false, which is the default value, the timeOfDay parameter refers to the time zone in which the facilities or incidents are located.
By setting timeOfDayIsUTC to true, the timeOfDay parameter refers to Coordinated Universal Time (UTC). Choose this option if you want to find what's nearest for a specific time, such as now, but aren't certain in which time zone the facilities or incidents will be located. Values: true | false |
timeOfDayUsage |
Description: Defines the way the timeOfDay value is used. The default is as defined in the network layer. Values: esriNATimeOfDayUseAsStartTime | esriNATimeOfDayUseAsEndTime |
returnZ |
This option was added at 10.1. Description: If true, z-values will be included in the returned routes and compressed geometry if the network dataset is z-aware. The default is false. |
overrides | Specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems. The value for this parameter needs to be specified in JavaScript Object Notation (JSON). The values can be a number, Boolean, or string.
The default value for this parameter is no value, which indicates not to override any solver settings. Overrides are advanced settings that should be used only after careful analysis of the results obtained before and after applying the settings. A list of supported override settings for each solver and their acceptable values can be obtained by contacting EsriTechnical Support. |
JSON Response Syntax
{
"routes" : {
"spatialReference" : { <spatialReference> },
"hasZ": <true|false>,
"hasM": <true|false>,
"features" : [ <array of <polyline> features> ]
},
"facilities" : {
"spatialReference" : { <spatialReference> },
"hasZ": <true|false>,
"features" : [ <array of <point> features> ]
},
"incidents" : {
"spatialReference" : { <spatialReference> },
"hasZ": <true|false>,
"features" : [ <array of <point> features> ]
},
"barriers" : {
"spatialReference" : { <spatialReference> },
"hasZ": <true|false>,
"features" : [ <array of <point> features> ]
},
"polylineBarriers" : {
"spatialReference" : { <spatialReference> },
"hasZ": <true|false>,
"features" : [ <array of <polyline> features> ]
},
"polygonBarriers" : {
"spatialReference" : { <spatialReference> },
"features" : [ <array of <polygon> features> ]
},
"directions" : [ {<route1>}, {<route2>},... ],
"messages" : [ {<message1>}, {<message2>},... ]
}
where each features object is defined as:
"features": [
{
"attributes": {
"<field1>": <value11>,
"<field2>": <value12>
},
"geometry": {<geometry1>}
},
{
"attributes": {
"<field1>": <value21>,
"<field2>": <value22>
},
"geometry": {<geometry2>}
}
]
each route object in the directions property are defined as:
{
"routeId": <routeId>,
"routeName": "<routeName>",
"summary": {
"totalLength": <totalLength>,
"totalTime": <totalTime>,
"totalDriveTime": <totalDriveTime>,
"envelope": {<envelope>}
},
"hasZ": <true|false>,
"features": [
{
"attributes" :
{
"length": <length1>,
"time": <time1>,
"text": "<text1>",
"ETA": <ETA>,
"maneuverType": "<maneuverType1>"
},
"compressedGeometry": "<compressedGeometry1>"
},
{
"attributes" :
{
"length": <length2>,
"time": <time2>,
"text": "<text2>",
"maneuverType": "<maneuverType2>"
},
"compressedGeometry": "<compressedGeometry2>"
}
]
}
and each message is defined as:
{ "type" : <type1>, "description" : <description1> }
JSON Response Example
{
"routes" : {"spatialReference" : {
"wkid" : 4326
},
"features" : [
{
"attributes" : {
"ObjectID" : 1,
"FacilityID" : 2,
"FacilityRank" : 1,
"Name" : "Accident 1 - Hospital 2",
"IncidentCurbApproach" : 1,
"FacilityCurbApproach" : 1,
"IncidentID" : 1,
"Total_Time" : 10.681003218051,
"Shape_Length" : 0.123693665336013
}
,
"geometry" :
{
"paths" :
[
[
[-122.395844761, 37.6832247680001],
[-122.395337, 37.6825930000001],
[-122.395127, 37.6822990000001],
[-122.395078, 37.6822100000001],
[-122.394961, 37.6820240000001],
[-122.394864, 37.681839],
[-122.394719, 37.681497],
[-122.39465, 37.681275],
[-122.394578, 37.681046],
[-122.3945, 37.681068],
[-122.39443, 37.6810760000001],
[-122.394464, 37.6812190000001],
[-122.40428, 37.780963],
[-122.404422, 37.781073],
[-122.404422001, 37.781073001],
[-122.404946, 37.7814910000001],
[-122.405487, 37.78193],
[-122.405962, 37.7823090000001],
[-122.405179949, 37.7829275240001]
]
]
}
}
]
},
"directions" : [
{
"routeId" : 1,
"routeName" : "Accident 1 - Hospital 2",
"summary" : {
"totalLength" : 8.08519598918001,
"totalTime" : 10.6666666666667,
"totalDriveTime" : 10.681003218051,
"envelope" : {
"xmin" : -122.408392,
"ymin" : 37.681046,
"xmax" : -122.39443,
"ymax" : 37.7829275239333,
"spatialReference" : {
"wkid" : 4326
}
}
},
"features" : [
{
"attributes" : {
"length" : 0,
"time" : 0,
"text" : "Start at Accident 1",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTDepart"
},
"compressedGeometry" : "+1m91-6fjtc+1vtgu+0+0"
},
{
"attributes" : {
"length" : 0.150853254241241,
"time" : 0.259400404989719,
"text" : "Go southeast on Bayshore Blvd",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTStraight"
},
"compressedGeometry" : "+1m91-6fjtc+1vtgu+18-1j+e-q+c-v"
},
{
"attributes" : {
"length" : 2.1656530667998,
"time" : 3.72155529726297,
"text" : "Make U-turn and go back on Bayshore Blvd",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTUTurn"
},
"compressedGeometry" : "+1m91-6fjra+1vtdi+4-d+9+2-b+v-g+t-h+p-t+15-10+14-10+v-1k+1c-4q+3l-29+1q-10+11-12+1b-f+o-n+18-1a+2j-6b+ct-8+o-3+l+0+14+3+u+9+l+1m+35+10+23+a+r+1v+4e"
},
{
"attributes" : {
"length" : 0.598385652527213,
"time" : 1.02499999850988,
"text" : "Continue on Bay Shore Blvd",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTStraight"
},
"compressedGeometry" : "+1m91-6fkdq+1vusg+h+t+f+15+c+n+1b+1n+l+10+8+9+b+b+g+a+e+6+1u+h+o+e+12+11+1i+1l+g+p+7+h"
},
{
"attributes" : {
"length" : 0.115576051175594,
"time" : 0.196666669100523,
"text" : "At fork keep left on Bay Shore Blvd",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTForkLeft"
},
"compressedGeometry" : "+1m91-6fk2s+1vv83+b+12+8+h+5+e+3+c+0+d"
},
{
"attributes" : {
"length" : 3.56891432413399,
"time" : 3.38341818004847,
"text" : "Take ramp on the left and go on US Hwy 101 N toward Civic Center/Bay Bridge",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTRampLeft"
},
"compressedGeometry" : "+1m91-6fk21+1vvat-p+2b-9+13-l+18-g+1n-k+1q-20+51-h+1j-2b+63-9+i-1d+2c-2a+4c-3f+5q-f+t-8+n-9+u-7+12-3+18+3+18+8+18+7+n+9+o+l+17+k+r+23+2i+j+t+d+s+b+u+32+9o+6+k+4+r+3+13-1+10-d+4e-5+q-6+l-f+q-k+o-j+g-1j+16-g+d-f+h-d+h-7+d-7+i-4+h-1+f+1+g+7+t+g+10+10+1j+8+l+7+j+4+n+3+n+2+1k"
},
{
"attributes" : {
"length" : 0.557037940125038,
"time" : 0.514848945662379,
"text" : "Go toward Seventh St",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTStraight"
},
"compressedGeometry" : "+1m91-6fkd1+201vc+1+p-1+p-l+6h-4+e-8+l-17+1q-b+l-6+g-5+j+0+s"
},
{
"attributes" : {
"length" : 0.139812714384474,
"time" : 0.193322874605656,
"text" : "Take ramp on the right to 7th St toward US Hwy 101",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTRampRight"
},
"compressedGeometry" : "+1m91-6fkfv+202d0+4+b+j+v+8+8+n+h+6+8+2+5+1+b-1+4-3+4"
},
{
"attributes" : {
"length" : 0.184959217304317,
"time" : 0.312160110566765,
"text" : "Continue on 7th St",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTStraight"
},
"compressedGeometry" : "+1m91-6fke4+202g3-44+39"
},
{
"attributes" : {
"length" : 0.344728539097515,
"time" : 0.589068286120892,
"text" : "Turn right on Folsom St",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTTurnRight"
},
"compressedGeometry" : "+1m91-6fki8+202jc+7o+64"
},
{
"attributes" : {
"length" : 0.198729099388571,
"time" : 0.340110473334789,
"text" : "Turn left on 5th St",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTTurnLeft"
},
"compressedGeometry" : "+1m91-6fkag+202pg-4e+3i"
},
{
"attributes" : {
"length" : 0.0605461300022504,
"time" : 0.145451977849007,
"text" : "Turn right on Minna St",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTTurnRight"
},
"compressedGeometry" : "+1m91-6fkeu+202t2+1b+12"
},
{
"attributes" : {
"length" : 0,
"time" : 0,
"text" : "Finish at Hospital 2",
"ETA" : -2209161600000,
"maneuverType" : "esriDMTStop"
},
"compressedGeometry" : "+1m91-6fkdj+202u4+0+0"
}
]
}
],
"messages" : [
]
}